﻿using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using BluePortal.Medias.Core;

namespace BluePortal.QuikStart.UserControls
{
    public partial class MediaChannels : System.Web.UI.UserControl
    {
        private IEnumerable channelsList;
        public IEnumerable ChannelsList
        {
            get { return channelsList; }
            set { channelsList = value; }
        }

        bool removeMode = false;
        public bool RemoveMode
        {
            get { return removeMode; }
            set { removeMode = value; }
        }
        public bool ImageRemoveMemberVisibility
        {
            get
            {
                return removeMode;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (channelsList != null)
                {
                    rpChannel.DataSource = channelsList;
                    rpChannel.DataBind();
                }
            }
        }

        protected void rpChannel_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "removeMember":
                    new BCChannelUser().DeleteUser(new Guid(e.CommandArgument.ToString()), Context.User.Identity.Name);
                    rpChannel.DataSource = channelsList;
                    Page.DataBind();
                    break;
            }
        }
    }
}